/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package auxiliares;

import indexacion.Indexador;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author marco
 */
public class Log {

    public static void registrarTexto(String rutaSalida, String texto) {

        try {
            File sFichero = new File(rutaSalida + System.getProperty("file.separator") + "log.txt");
            BufferedWriter bw = null;
            // Si ya existe el fichero se añade a lo que ya contiene
            if (sFichero.exists() && sFichero.canWrite() && sFichero.isFile()) {
                bw = new BufferedWriter(new FileWriter(sFichero,true));
                bw.write(texto);
                bw.newLine();
                bw.close();
            } else if (!sFichero.exists() && sFichero.createNewFile()) {
                bw = new BufferedWriter(new FileWriter(sFichero,false));
                bw.write(texto);
                bw.newLine();
                bw.close();
            }

        } catch (IOException ex) {
            Logger.getLogger(Indexador.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
